package org.nanotek.persistence.jpa.atlas;

import java.util.List;

import org.nanotek.base.atlas.country.Country;
import org.nanotek.persistence.jpa.BrainzBaseDAO;

public class CountryDAO extends BrainzBaseDAO<Country>{

	public CountryDAO() {
		postContruct();
	}
	
	public void postContruct(){
		this.baseClass = Country.class;
	}

	@SuppressWarnings("unchecked")
	public List<Country> findCountryByName(String value)
	{ 
		String jpql = "Select c from Country c inner join StringBase d where c.countryName like '%:value%'";
//		Root <?> rootCountry = getCriteriaBuilder().createQuery(List.class).from(baseClass);
//		Join<Country,?> join = rootCountry.join("countryName");
		return entityManager.createQuery(jpql).setParameter("value", value).getResultList();
	}
 

	@SuppressWarnings("unchecked")
	public List<Country> findByExample(Country country)
	{
		String jpql = "Select c from Country c where c = :country";
//		Root <?> rootCountry = getCriteriaBuilder().createQuery(List.class).from(baseClass);
//		Join<Country,?> join = rootCountry.join("countryName");
		return entityManager.createQuery(jpql).setParameter("country", country).getResultList();
	}
 
}
